<!DOCTYPE html>
<html lang="zh-CN">
<head>
 
<#include "bases/global_style.ftl">
<#include "bases/global_js.ftl">
<#include "bases/combo.ftl">

    <style type="text/css">
         label{width: 70px;text-align: left;}
    </style>
        
    <script>
        var curent_page=${currentpage};

        var dataform;
        jQuery(document).ready(function()
        {
            var optInit = getOptionsFromForm();
            $("#Pagination").pagination(${totalRecord}, optInit);
            App.init();
            dataform=$("#dataform").validate();
			
        });
 
        function doTableSort(ID)
        {
            $("#postsortfield").val(ID);
            $("#currentpage").val(0);
            $("#searchform").submit();
        }

        function setPersonInfo(id){
        	
    		$.ajax({
    			type : "POST",
        		url : CONTEXT+'/get_person_byexchageid?id='+id,
        		dataType : "json",  
      	      	success : function(data) {
      	      	  	$("#dataform #accountName").val(data.accountName);
      	          	$("#dataform #account").val(data.account);
      	         	$("#dataform #balance").val(data.fare/100);
      	          	$("#dataform #accountid").val(data.accountid);
      	      	}
    		});
        }
 
        function showRefundDiv(id,serialNum){

            $.ajax({
                type :"POST",
                url : CONTEXT+'/get_record_byexchageid?id='+id,
                dataType : "json",  
      	      	success : function(data) {
      	      		if(data.result==true){
      	      			setPersonInfo(id);
      	   				$("#execChargid").val(serialNum);
      	   				$("#chargeid").val(id);
      	   				$("#variable").val(data.variable);
      	   				$("#amount_deci").attr("max",data.variable/100);
      	   		 		showPopup("refundDiv");
   	        		}else{
   	        			jAlert(data.msg);
   	        		}
          	    }
            });
        }

        function addEntity(){
        	dataform.form();
        	if(dataform.valid()){
                var a ;
                var nowtime = new Date();
                var strtemp = ""+nowtime.getHours()+nowtime.getMinutes()+nowtime.getSeconds()+nowtime.getMilliseconds();
                a=strtemp;

                $("#amount_deci").val($("#amount_deci").val()*100);
                $("#loading").showLoading(); 
        		$.ajax({  
          		      type : "POST",  
          		      url :  "${base}/add_refund_record/" + a,
          		      data:  $("#dataform").serialize(),
          		      dataType : "json",  
          		      success : function(data) {
    	      		      $('#loading').hideLoading();
    		      		  if(data.result ==true) {
    	                      window.location.reload();
    	      		      }else{
                              jAlert(data.msg);
                          }
                            	
          		      }
      		    }); 
                
    	    }
        }

        function doDownloadExcel()
        {
        	$("#searchform").attr("action","<@spring.url '/download_exchange_record'></@spring.url>");
        	$("#searchform").submit();
        }
 
        function showPopup(div) 
        {//弹出层
            var backDiv = document.getElementById("backDiv");
            backDiv.style.top = "0%";//设置弹出层距离上边界的距离
            backDiv.style.left = "0%";//设置弹出层距离左边界的距离
            backDiv.style.width = "100%";//设置弹出层的宽度
            backDiv.style.height = "100%";//设置弹出层的高度
            backDiv.style.visibility = "visible";

            var formDiv = document.getElementById(div);
            formDiv.style.top = "10%";//设置弹出层距离上边界的距离
            formDiv.style.left = "30%";//设置弹出层距离左边界的距离
            formDiv.style.width = "40%";//设置弹出层的宽度
            formDiv.style.height = "auto";//设置弹出层的高度
            formDiv.style.visibility = "visible";
        }
 
 
        function hidePopup() 
        {//关闭层
   
            var backDiv = document.getElementById("backDiv");
            backDiv.style.visibility = "hidden";

            var refundDiv = document.getElementById("refundDiv");
            refundDiv.style.visibility = "hidden";
        }
        
        function showBatteryList(exelecRecordid){
        	showDialog("${base}/electric_charging_battery_list?exelecRecordid="+exelecRecordid,"850","450");
        }
 
    </script>
  
</head>

<body>

	<div id="backDiv" onclick="allDivHide()" style="position: absolute;visibility: hidden;position:fixed;overflow: hidden;solid: #000000;background-color: #000000;padding: 1px;z-index: 99;filter:alpha(opacity=50);opacity: 0.5;"></div>

	<!-- 添加退款 -->
	<div id="refundDiv" class="row-fluid" style="position: absolute;visibility: hidden;overflow: hidden;padding: 1px;z-index: 100;background-color: #FFFFFF;">
		<div class="span12">
        <div class="portlet box green" style="margin: -1px;">
            <div class="portlet-title">
                <div class="caption"><i class="fa fa-edit"></i>添加个人换电记录退款</div>
                <a href="javascript:hideEditTable();" class="remove"></a>
            </div>
            
            <div class="portlet-body flip-scroll">
            	<form id="dataform" method="POST">
            	
            	<input type="hidden" name="accountid" id="accountid">
            	<input type="hidden" name="type" id="type" value="0">
                <input type="hidden" name="status" id="status" value="2">
            	
            	<table class="table-bordered table-striped table-condensed flip-content">
            		<tbody role="alert" aria-live="polite" aria-relevant="all">
         
            		<tr class="even">
            			<td style="text-align: right;">搜索流水号</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="execChargid" readonly/>
							<input type="hidden" id="chargeid" name="execChargid">
            			</td>
            		</tr>
            		<tr class="odd">
            			<td style="text-align: right;">账号</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="account" name="account" readonly />
            			</td>
            		</tr>
            		<tr class="even">
            			<td style="text-align: right;">姓名</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="accountName" readonly/>
            			</td>
            		</tr>
            		<tr class="odd">
            			<td style="text-align: right;">换电费用</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="balance" readonly/>
            				<input type="hidden" id="variable">
            			</td>
            		</tr>
                    <tr class="even">
            			<td style="text-align: right;">退款金额<span class="fill-must">*</span></td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="number" id="amount_deci" name="amount" required max="1000" data-msg-max="退款金额要小于等于剩余换电费用" placeholder="请输入退款金额"/>
            			</td>
            		</tr>
            		 <tr class="odd">
            			<td style="text-align: right;">退款理由<span class="fill-must">*</span></td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="reason" name="reason" required placeholder="请输入异常理由不超过20个字"/>
            			</td>
            		</tr>
            		</tbody>
            		</table>
            		<div class="controls controls-row" style="text-align: right;">
                        <input type="button" value="保存" class="btn green" onclick="addEntity()"/>
                        <input type="button" value="取消" class="btn green" onclick="hidePopup()" />
                    </div>
            	</form>
            </div>
        </div>
        </div>
	</div>
 
<div class="page-container row-fluid">

<#include "bases/sidebar.ftl">
<#include "bases/navhead.ftl">

    <div class="page-content secMenu-content" id="loading">
     
        <div class="container-fluid">
 
            <div class="row-fluid">
                <div class="span12">
                    <div class="portlet box green">
                        <div class="portlet-title">
                            <div class="caption"><i class="fa fa-cogs"></i>换电记录列表</div>
	                        <div class="tools">
                                <a href="javascript:window.location.reload()" class="reload"></a>
                            </div>                           
                        </div>
                        <div class="portlet-body flip-scroll">
                            <form id="searchform" action="${base}/electric_charging_record_manage" method="POST" class="form-inline">
                               
                                <div class="controls controls-row">
	                                    <label for="tel" class="">手机号：</label>
	                                    <input  name="tel"  id="tel"  type="text" class="form-control sheet-searchInput"value="<#if tel??>${tel}</#if>"/>
                                   
	                                    <label for="carbrand">车牌号：</label>
	                                    <input  name="carbrand"  id="carbrand"  type="text" class="form-control sheet-searchInput"value="<#if carbrand??>${carbrand}</#if>"/>
 	                                    <label for="name">站点：</label>
		                                <select id="siteid" name="siteid" class="form-control sheet-searchInput" >
		                                <option value="">===请选择===</option>
		                                <#if siteList??>
			                                <#list siteList as slist> 
			                                    <option value="<#if slist.getKey()??>${slist.getKey()}</#if>"  <#if siteid??><#if siteid=="${slist.getKey()}">selected="selected"</#if></#if>><#if slist.getValue()??>${slist.getValue()}</#if></option>
			                                </#list>
		                                  </#if>
		                                </select>
                                  
	                                    <label for="name">所属公司：</label>
		                                <select id="companyid" name="companyid" class="form-control sheet-searchInput" >
		                                <option value="">===请选择===</option>
		                                <#if companyList??>
			                                <#list companyList as clist> 
			                                    <option value="<#if clist.getKey()??>${clist.getKey()}</#if>"  <#if companyid??><#if companyid=="${clist.getKey()}">selected="selected"</#if></#if>><#if clist.getValue()??>${clist.getValue()}</#if></option>
			                                </#list>
		                                  </#if>
		                                </select>

                                </div>
                                
                                <div class="controls controls-row" style="margin-top: 20px">
	                                    <label for="name">车型：</label>
		                                <select id="cartypeid" name="cartypeid" class="form-control sheet-searchInput" >
		                                <option value="">===请选择===</option>
		                                <#if cartypeList??>
			                                <#list cartypeList as clist> 
			                                    <option value="<#if clist.getKey()??>${clist.getKey()}</#if>"  <#if cartypeid??><#if cartypeid=="${clist.getKey()}">selected="selected"</#if></#if>><#if clist.getValue()??>${clist.getValue()}</#if></option>
			                                </#list>
		                                  </#if>
		                                </select>
                                
	                                    <label for="tel" class="">换电时间：</label>
	                                    <input  name="begintime"  id="begintime"  type="text" class="form-control sheet-searchInput" value="<#if begintime??>${begintime}</#if>" onFocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })"/>
	                                   
	                                    <label for="carbrand">至：</label>
	                                    <input  name="endtime"  id="endtime"  type="text" class="form-control sheet-searchInput" value="<#if endtime??>${endtime}</#if>" onFocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" />
	                                  
	                                    <button type="submit" class="btn blue" onclick="searchButton()">搜索 </button>
	                                
	                                    <input  type="hidden" id="currentpage" name="page" value="0" />
	                                    <input  type="hidden" id="postsortfield" name="sortfield" value="<#if sortfield??>${sortfield}</#if>" />
                                
                                </div>
                                
                                <div class="controls controls-row"  style="margin-top: 20px">
									<button type="button" class="btn green" onclick="doDownloadExcel()">导出</button>
								</div>
                                 <table  class="table table-bordered table-hover table-striped table-condensed list-table">
                                    <thead class="flip-content">
                                    <tr>
                                    	  <th style="text-align: center;">订单流水号</th>
					          	          <th style="text-align: center;">时间</th>
								          <th style="text-align: center;">车辆</th>
								          <th style="text-align: center;">费用/余额</th>
								          <th style="text-align: center;">对公余额</th>
								          <th style="text-align: center;">司机账户ID</th>
								          <th style="text-align: center;">所属公司</th>
								          <th style="text-align: center;">SOC</th>
								          <th style="text-align: center;">行驶/总里程</th>
								          <th style="text-align: center;">TBOX里程</th>
								          <th style="text-align: center;">应收计费里程</th>
								          <th style="text-align: center;">优惠券使用</th>
								          <th style="text-align: center;">网点</th>
								          <th style="text-align: center;">备注</th>
								          <th style="text-align: center;">状态</th>
								          <th style="text-align: center;width: 100px"">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <#list exchange_electric_record_list as eer>
                                    <tr>
                                    	<td style="text-align: center;"><#if eer.getSerialNum()??>${eer.getSerialNum()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getCreatedate()??>${eer.getCreatedate()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getCarbrand()??>${eer.getCarbrand()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getFare()??>${eer.getFare()/100}</#if>/<#if eer.getAfter_consum_balance()??>${eer.getAfter_consum_balance()/100}</#if></td>
                                        <td style="text-align: center;"><#if eer.getCompany_available_balance()??>${eer.getCompany_available_balance()/100}</#if></td>
                                        <td style="text-align: center;"><#if eer.getDriverId()??>${eer.getDriverId()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getCompanyname()??>${eer.getCompanyname()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getSoc()??>${eer.getSoc()}%</#if></td>
                                        <td style="text-align: center;"><#if eer.getTravelMileage()??>${eer.getTravelMileage()}</#if>/<#if eer.getTbox()??>${eer.getTbox()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getRefermiles()??>${eer.getRefermiles()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getBillingmileage()??>${eer.getBillingmileage()}</#if></td>
                                        <td style="text-align: center;">0</td>
                                        <td style="text-align: center;"><#if eer.getSitename()??>${eer.getSitename()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getComment()??>${eer.getComment()}</#if></td>
                                        <td style="text-align: center;"><#if eer.getStatusName()??>${eer.getStatusName()}</#if></td>
                                        <td style="text-align: center;">
                                         
                                         
                                         	<a id="editButton" onclick="showBatteryList(<#if eer.getId()??>${eer.getId()}</#if>)"
                                               class="btn btn-success btn-grad">电池</a>
                                            <a id="goToAnotherPage" onclick="showRefundDiv('${eer.getId()}','${eer.getSerialNum()}')"
                                               class="btn btn-success btn-grad">退款</a>
                                      
                                        </td>
                                    </tr>
                                    </#list>
                                    </tbody>
                                </table>
                                 <div class="controls controls-row">
                                    <div id="Pagination" class="pagination"></div>
                                 </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
  </div>
 
</body>
</html>

 
